Getting started with testing the DocuGenerate API is a breeze with Postman, a powerful API development and testing tool. Postman simplifies the process of making API requests, inspecting responses, and streamlining your testing workflow.
In this article, we’ll walk through the process using the Job Offer Letter from the 4 Different Ways to Generate Job Offer Letters in Bulk blog post to generate multiple documents.
Postman is a comprehensive API development environment that allows you to design, test, and document APIs. It provides a user-friendly interface for sending HTTP requests, organizing your API endpoints, and managing your testing environments. Whether you’re a developer, tester, or part of a DevOps team, Postman can enhance your API testing and development processes.
To simplify the testing process, import the DocuGenerate API Collection into Postman. After importing the collection, you should see the Template
and Document
endpoints listed like in the following image:
To begin testing with the DocuGenerate API in Postman, it’s essential to set up the Authorization
section in the Postman collection.
While this article utilizes the demo key 491c000c5fad32ed7787005b0723ad55
, it’s recommended to substitute it with your unique API key for actual usage. You can retrieve your individual API key from the Settings page after logging into DocuGenerate.
Navigate to the Document / Generate Document
endpoint within the Postman collection and specify the template_id
parameter. If you created a template with the Job Offer Letter, use the id of that template.
Also, make sure to select form-data
for the body type so that the POST request uses the multipart/form-data content type, necessary for successfully calling the API.
For the data
parameter, input the dataset intended for document generation. The expected format is an array of JSON objects, where each JSON object has the keys corresponding to the template’s merge tags.
While the output_format
parameter is optional, with the default value being .docx
, you have the flexibility to generate the documents in alternative formats like .pdf
, .doc
or .odt
, as outlined in the API Reference.
Upon processing, the API returns a JSON object for the newly created document. Within the response object, the document_uri
field provides a link to the generated PDF:
{
"filename": "Job Offer Letter.pdf",
"created": 1696365915580,
"data_length": 20,
"name": "Job Offer Letter",
"format": ".pdf",
"template_id": "ZtHBhb9jLh6TcZuaVteI",
"document_uri": "https://storage.googleapis.com/docugenerate.appspot.com/documents/2GhuZ9GIDbFAl2PdEeAr/Job%20Offer%20Letter.pdf?GoogleAccessId=firebase-adminsdk-4i7q5%40docugenerate.iam.gserviceaccount.com&Expires=1834037410&Signature=J2Y7g%2Be3Xr7CvRTfskT3v8%2BGMS6tfFzuEDwvIPM7zH3xQGHcEekos9s7hQTDjeYbYKrJngxhVeOhAAbKhLAahZqwrKBSyuyoXhCMiwiS0Uhfpe8W9a%2BZ973OlBNnOpxZ18DxDwZPmYNq4afFKuxaaNUdYFUXE3RiG5Fs7KOJjNZ8%2FDcSHVm1%2FITzamT96SdYm6KTLNEiuS0bjYaJZ97hAT7DxG5dMRinIZQ1pkRPjXrz8U%2Fe%2BdVeCWMVps6HzONECCM4ismU26waadXiWcsqsd9qi9STAsnc7caaEQASLoZkO6Y0wJXcJao%2FBsby1P7OY2XJx%2F8NyCgzcFWscObgbw%3D%3D",
"id": "7JxcR3Q1EVKqljsTvHqc"
}
By leveraging Postman, you can streamline your testing process, identify potential issues, and ensure the smooth integration of DocuGenerate into your applications.